package cc.mrbird.event.service.impl;

import cc.mrbird.common.domain.QueryRequest;
import cc.mrbird.common.service.impl.BaseService;
import cc.mrbird.event.dao.EventInformationMapper;
import cc.mrbird.event.domain.EventInformation;
import cc.mrbird.event.service.EventInformationService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service("eventInformationService")
public class EventInformationServiceImpl extends BaseService<EventInformation> implements EventInformationService {
    private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private EventInformationMapper eventInformationMapper;

    @Override
    public List<EventInformation> findAllEvent(String nextTime) {
        List<EventInformation> eventInformationList = eventInformationMapper.findEventInformationList(nextTime);
        return eventInformationList;
    }

    @Override
    @Transactional
    public void add(EventInformation eventInformation) {
        this.save(eventInformation);
    }

    @Override
    public List<EventInformation> findAllTypeAndId() {
        return eventInformationMapper.findAllTypeAndId();
    }

    @Override
    public List<EventInformation> findAllByAlarmType() {
        return eventInformationMapper.findAllByAlarmType();
    }

    @Override
    public List<EventInformation> fingAllByIdsAndType(String ids) {
        List<EventInformation> list = new ArrayList<>();
        List<String> list1 = Arrays.asList(ids.split(","));
        for (String s : list1) {
            EventInformation eventInformation = eventInformationMapper.findById(Long.parseLong(s));
            list.add(eventInformation);
        }
        return list;
    }

}
